// 状态类型
interface State {
  isActive: boolean;
}

// 动作类型
type Action = { type: "toggle" };
const switchReducer = (state: State, action: Action): State => {
  switch (action.type) {
    case "toggle":
      return { ...state, isActive: !state.isActive };
    default:
      throw new Error();
  }
};

export default switchReducer;
